/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.desitek.cricket.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;


/**
 * 
 * @author Dhiraj
 */
@Entity
@Table(name = "desi_user")
@NamedQueries( {
		@NamedQuery(name = "User.findByUserId", query = "SELECT u FROM User u WHERE u.userId = :userId"),
		@NamedQuery(name = "User.findByUserBirthDate", query = "SELECT u FROM User u WHERE u.userBirthDate = :userBirthDate"),
		@NamedQuery(name = "User.findByUserCountry", query = "SELECT u FROM User u WHERE u.userCountry = :userCountry"),
		@NamedQuery(name = "User.findByUserCreateDate", query = "SELECT u FROM User u WHERE u.userCreateDate = :userCreateDate"),
		@NamedQuery(name = "User.findByUserDisplayname", query = "SELECT u FROM User u WHERE u.userDisplayname = :userDisplayname"),
		@NamedQuery(name = "User.findByUserEmail", query = "SELECT u FROM User u WHERE u.userEmail = :userEmail"),
		@NamedQuery(name = "User.findByUserLocation", query = "SELECT u FROM User u WHERE u.userLocation = :userLocation"),
		@NamedQuery(name = "User.findByUserPassword", query = "SELECT u FROM User u WHERE u.userPassword = :userPassword"),
		@NamedQuery(name = "User.findByUserSecurityCode", query = "SELECT u FROM User u WHERE u.userSecurityCode = :userSecurityCode"),
		@NamedQuery(name = "User.findByUserStatus", query = "SELECT u FROM User u WHERE u.userStatus = :userStatus"),
		@NamedQuery(name = "User.findByUsername", query = "SELECT u FROM User u WHERE u.username = :username") })
public class User implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "user_id", nullable = false)
	private Integer userId;
	@Column(name = "user_birth_date")
	@Temporal(TemporalType.TIMESTAMP)
	private Date userBirthDate;
	@Column(name = "user_country")
	private String userCountry;
	@Column(name = "user_create_date")
	@Temporal(TemporalType.TIMESTAMP)
	private Date userCreateDate;
	@Column(name = "user_displayname")
	private String userDisplayname;
	@Column(name = "user_email", nullable = false)
	private String userEmail;
	@Column(name = "user_location")
	private String userLocation;
	@Column(name = "user_password", nullable = false)
	private String userPassword;
	@Column(name = "user_security_code", nullable = false)
	private String userSecurityCode;
	@Column(name = "user_status", nullable = false)
	private boolean userStatus;
	@Column(name = "username")
	private String username;
	@JoinColumn(name = "user_group", referencedColumnName = "grp_id")
	@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
	@ManyToOne
	private Groups userGroup;

	public User() {
	}

	public User(Integer userId) {
		this.userId = userId;
	}

	public User(Integer userId, String userEmail, String userPassword,
			String userSecurityCode, boolean userStatus) {
		this.userId = userId;
		this.userEmail = userEmail;
		this.userPassword = userPassword;
		this.userSecurityCode = userSecurityCode;
		this.userStatus = userStatus;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public Date getUserBirthDate() {
		return userBirthDate;
	}

	public void setUserBirthDate(Date userBirthDate) {
		this.userBirthDate = userBirthDate;
	}

	public String getUserCountry() {
		return userCountry;
	}

	public void setUserCountry(String userCountry) {
		this.userCountry = userCountry;
	}

	public Date getUserCreateDate() {
		return userCreateDate;
	}

	public void setUserCreateDate(Date userCreateDate) {
		this.userCreateDate = userCreateDate;
	}

	public String getUserDisplayname() {
		return userDisplayname;
	}

	public void setUserDisplayname(String userDisplayname) {
		this.userDisplayname = userDisplayname;
	}

	public String getUserEmail() {
		return userEmail;
	}

	public void setUserEmail(String userEmail) {
		this.userEmail = userEmail;
	}

	public String getUserLocation() {
		return userLocation;
	}

	public void setUserLocation(String userLocation) {
		this.userLocation = userLocation;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	public String getUserSecurityCode() {
		return userSecurityCode;
	}

	public void setUserSecurityCode(String userSecurityCode) {
		this.userSecurityCode = userSecurityCode;
	}

	public boolean getUserStatus() {
		return userStatus;
	}

	public void setUserStatus(boolean userStatus) {
		this.userStatus = userStatus;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public Groups getUserGroup() {
		return userGroup;
	}

	public void setUserGroup(Groups userGroup) {
		this.userGroup = userGroup;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (userId != null ? userId.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are
		// not set
		if (!(object instanceof User)) {
			return false;
		}
		User other = (User) object;
		if ((this.userId == null && other.userId != null)
				|| (this.userId != null && !this.userId.equals(other.userId))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "com.desitek.cricket.entity.User[userId=" + userId + "]";
	}

}
